<%@page import="domain.service.Utils"%>
<%@page import="java.util.List"%>
<%@page import="domain.data.QnAPersistenceManager"%>
<%@page import="javax.jdo.PersistenceManager"%>
<%@page import="domain.model.Domain"%>
<%@page import="javax.jdo.Query"%>
<%@page import="java.util.Random"%>
<%@page import="java.util.Date"%>
<%@page import="java.util.Calendar"%>
<%
PersistenceManager psms = QnAPersistenceManager.get().getPersistenceManager();
Calendar cdr = Calendar.getInstance();
Date dat=new Date();
cdr.set(Calendar.DAY_OF_MONTH, 24);
cdr.set(Calendar.MONTH, 7);
cdr.set(Calendar.YEAR, 2011);

long val1=cdr.getTimeInMillis();

long val2=dat.getTime();


Random r=new Random();
long randomTS=(long)(r.nextDouble()*(val2-val1))+val1;
Date dd=new Date(randomTS);

Query query_top = psms.newQuery(Domain.class);
query_top.setFilter("lastUpdateDate < date");
query_top.declareParameters("java.util.Date date");
query_top.setOrdering("lastUpdateDate desc");
query_top.setRange(0, 20);
@SuppressWarnings("unchecked")
List<Domain> listDomains=  (List<Domain>)query_top.execute(dd);
%>
<div class="ti">Random site</div>
<ul class="li">
	<%
	for(int i=0;i<listDomains.size();i++)
	{
	%>
		<li><a href="/domain/<%=listDomains.get(i).getName() %>" title="<%=listDomains.get(i).getName() %>"><%=Utils.cutString(listDomains.get(i).getName(),20) %></a></li>
	<%
	}
	%>
</ul>
<div class="cl"></div>